package com.example.myapplication;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

import okhttp3.Call;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class UploadFileTest {
    /*@Test
    public void uploadFile() throws InterruptedException {
        OkHttpClient okHttpClient = new OkHttpClient();
        String loadPath = "C:/Users/xiaoman/Desktop";
        File file1 = new File(loadPath+"/"+"1.txt");
        File file2 = new File(loadPath+"/"+"2.txt");
        MultipartBody multipartBody = new MultipartBody.Builder()
                .addFormDataPart("file1", file1.getName(), RequestBody.create(MediaType.parse("text/plain"), file1))
                .addFormDataPart("file2", file2.getName(), RequestBody.create(MediaType.parse("text/plain"), file2))
                .build();

        Request request = new Request.Builder().url("https://www.httpbin.org/post").post(multipartBody).build();
        Call call = okHttpClient.newCall(request);
        try {
            Response response = call.execute();
            if (response.isSuccessful()){
                System.out.println(response.body().string());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }*/
}
